package day8;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @author oldliu
 * @since 1.0
 */
public class FileTest4 {
    public static void main(String[] args) {
        //输出流，到文件
        //目录在，文件不在，自动创建
        OutputStream out = null;
        try {
            out = new FileOutputStream("E:\\temp\\java78\\chenyi\\java78.txt", true);
            out.write(65);
            out.write(1000);
            out.write(66);//出异常
            out.write(67);
            out.write(new byte[]{97, 98, 99, 102});
            out.write("陈毅是个big帅哥".getBytes());
            //out.close();//隐患！！！
        } catch (Exception e) {//FileNotFound检查异常，必须要管。。。
            e.printStackTrace();
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (Exception e) {
                     e.printStackTrace();
                }
            }
        }

    }
}
